package com.example.qundui.learndemo.lvtest;

import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;



import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Adapter;
import android.widget.TextView;
import android.widget.Toast;


import com.example.mylibrary.utils.commonutils.MyUtils;
import com.example.qundui.learndemo.R;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by qundui on 2017/4/30.
 */
public class TestRv extends bases {
    private XRecyclerView lv;
    private List<String> stringList;
    int i=1;
    @Override
    protected void doBusy() {
        lv= (XRecyclerView) findViewById(R.id.xv);
        final String[] urlstrs={"https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1493560727&di=af5879b0fea14025df675ef7aa4cca90&src=http://pic.eastlady.cn/uploads/tp/201704/9999/b129d07989.jpg"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1494132792&di=3ccdf5c8c5a7f7b5a4de31c529fb3ccd&imgtype=jpg&er=1&src=http%3A%2F%2Fm.vstou.com%2Fimg%2F201601%2Fxxq8.jpg",
                "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1164631352,4251729771&fm=23&gp=0.jpg",
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1493538096506&di=0c70da268c81435873a71dda4babab93&imgtype=0&src=http%3A%2F%2Fv1.qzone.cc%2Favatar%2F201408%2F06%2F18%2F29%2F53e203811edc4584.jpg%2521200x200.jpg"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1493538096505&di=0712ba9658961ee362fd1d5d76dfb27d&imgtype=0&src=http%3A%2F%2Fwww.szbowen.net%2Fd%2Ffiles%2Fimage%2Fbd1675837.jpg"};
        stringList = new ArrayList<>();
        for(int i=0;i<urlstrs.length;i++){
            stringList.add(urlstrs[i]);

        }
        final RecyclerView.Adapter mDataAdapter=new MyAdapter(this, stringList);
        lv.setAdapter(mDataAdapter);
        lv.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                //refresh data here
                MyUtils.printLog("gsc","onRefresh()");
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        lv.refreshComplete();
                    }
                },2000);
            }

            @Override
            public void onLoadMore() {
                // load more data here
                MyUtils.printLog("gsc","onLoadMore");
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        lv.refreshComplete();
                    }
                },2000);
            }
        });

        lv.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));

    }
    @Override
    protected int getLayout() {
        return R.layout.rv_test;
    }
}
